<template>

    <el-dialog title="新增委托合同" :visible="contractAdd" @close="dialogClose" width="75%" :close-on-click-modal="false" class="dialog">
        
        <el-tabs type="card" class="tab">
            <el-tab-pane label="第1页">
                <Contract1 @submit="submit"></Contract1>
            </el-tab-pane>
            <el-tab-pane label="第2页">
                <Contract2 @submit="submit"></Contract2>
            </el-tab-pane>
            <el-tab-pane label="第3页">
                <Contract3 @submit="submit"></Contract3>
            </el-tab-pane>
            <el-tab-pane label="第4页">
                <Contract4 @submit="submit"></Contract4>
            </el-tab-pane>
            <el-tab-pane label="第5页">
                <Contract5 @submit="submit"></Contract5>
            </el-tab-pane>
            <el-tab-pane label="第6页">
                <Contract6 @submit="submit"></Contract6>
            </el-tab-pane>
            <el-tab-pane label="第7页">
                <Contract7 @submit="submitFinal" @submitLot="submitLot" :wthtbh="this.wthtbh"></Contract7>
            </el-tab-pane>
        </el-tabs>

    </el-dialog>

</template>
<script>
import { addData,addLotData,uploadExcel } from '@/api/auctionManage/entrustmentContract';
import Contract1 from './contract1.vue';
import Contract2 from './contract2.vue';
import Contract3 from './contract3.vue';
import Contract4 from './contract4.vue';
import Contract5 from './contract5.vue';
import Contract6 from './contract6.vue';
import Contract7 from './contract7.vue';
export default {
    components:{
        Contract1,
        Contract2,
        Contract3,
        Contract4,
        Contract5,
        Contract6,
        Contract7,
    },
    props: {
        contractAdd: {
            type: Boolean
        },
    },
    data () {
        return {
            lotForm: [
                
            ],
            wthtbh: '',
            ruleForm: {

                // wthtbh: "",//委托合同编号
                wthtmc: '',//委托合同名称
                wtr: "",//委托人
                wtdlr: "",//委托代理人
                pmr: "",//拍卖人
                pmdlr: "",//拍卖代理人
                bdzmc: "",//标的总名称
                zblj: 0,//总保留价
                zqpj: 0,//总起拍价
                zecblj: 0,//总二次保留价
                zjdbfb: 0,//总降低百分比
                pmfs: "",//拍卖方式
                wtpgr: "",//委托评估人
                pgfycdr: "",//评估费用承担人
                jdr: "",//鉴定人
                jdfycdr: "",//鉴定费用承担人
                pmksrq: "",//拍卖开始日期
                pmdd: "",//拍卖地点
                ggksrq: "",//公告开始时间
                ggjsrq: "",//公告结束时间
                ggmtmc: "",//公告媒体名称
                sfkygg: 'true',//保留价与保证金是否可以公告
                bzj: 0,//保证金
                bzjzbljbfb: 0,//保证金所占保留价百分比
                jmrsxz: '',//竞买人数选择
                zdjmrs: 0,//最低竞买人数
                sflhpm: 'true',//是否同意联合拍卖
                jfr: "",//交付人
                jfjzrq: "",//交付截止日期
                jfdd: "",//交付地点
                jffs: "",//交付方式
                bgfcdr: "",//保管费承担人
                yjzcjjbfb: 0,//佣金占成交价百分比
                hlfybk: "",//合理费用包括
                hlfyje: 0,//合理费用金额
                hlfxzts: 0,//合理费限制天数
                jkzffs: "",//价款支付方式
                jkzfqx: "",//价款支付期限
                pmccyy: "",//拍卖撤除原因
                wscxz: "",//标的未售出后选择
                xdlhts: 0,//限定领回天数
                wlhclfs: "",//未领回处理方式
                bmnr: "",//保密内容
                wyj: 0,//违约金
                wyjzbljbfb: 0,//违约金占保留价百分比
                wyzr: "",//违约责任
                zyjjxz: "1",//争议解决选择
                zcwyhmc: "",//仲裁委员会名称
                rmfymc: "",//人民法院名称
                ydy: "",//约定一
                yde: "",//约定二
                yds: "",//约定三
                htksrq: "",//合同开始时间
                htjsrq: "",//合同结束时间
                wtrqz: "",//委托人签字
                wtrkhh: "",//委托人开户行
                wtrzh: "",//委托人账号
                wtrdh: "",//委托人电话
                wtrqzrq: "",//委托人签字日期
                pmrqz: '',//拍卖人签字
                pmrkhh: "",//拍卖人开户行
                pmrzh: "",//拍卖人账号
                pmrdh: "",//拍卖人电话
                pmrqzrq: "",//拍卖人签字日期
                pmdw: "",//拍卖单位
                pmje: 0,//拍卖金额
                remark: "",

            },

            rules: {
                wtr: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                pmr: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                bdzmc: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                zblj: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                zqpj: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                pmfs: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                pmksrq: [
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                pmdd: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                ggksrq: [
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                ggjsrq: [
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                sfkygg: [
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                zdjmrs: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                sflhpm: [
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                jfr: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                jfjzrq: [
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                jfdd: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                jffs: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                bgfcdr: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                jkzffs: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                jkzfqx: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                pmccyy: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                wscxz: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                xdlhts: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                wlhclfs: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                wyzr: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                zyjjxz: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                zcwyhmc: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                rmfymc: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                ydy: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                yde: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                yds: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                htksrq: [
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                htjsrq: [
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                wtrqz: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                wtrkhh: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                wtrzh: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                wtrdh: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                wtrqzrq: [
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                pmrkhh: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                pmrzh: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                pmrdh: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                pmrqzrq: [
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                pmdw: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                pmje: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                remark: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                ggmtmc: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                yjzcjjbfb: [
                    { required: true, message: '请选择', trigger: 'change' }
                ],
                hlfybk: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                hlfyje: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
                hlfxzts: [
                    { required: true, message: '请输入', trigger: 'change' }
                ],
            }
        };
    },
    methods: {

        submitForm () {
            // this.$refs.addForm.validate((valid) => {
                // if (valid) {
                    this.ruleForm.zblj = parseInt(this.ruleForm.zblj);
                    this.ruleForm.zqpj = parseInt(this.ruleForm.zqpj);
                    this.ruleForm.zecblj = parseInt(this.ruleForm.zecblj);
                    this.ruleForm.bzj = parseInt(this.ruleForm.bzj);
                    this.ruleForm.wyj = parseInt(this.ruleForm.wyj);
                    this.ruleForm.pmje = parseInt(this.ruleForm.pmje);
                    this.ruleForm.hlfyje = parseInt(this.ruleForm.hlfyje);
                    this.ruleForm.zdjmrs = parseInt(this.ruleForm.zdjmrs);
                    this.ruleForm.xdlhts = parseInt(this.ruleForm.xdlhts);
                    this.ruleForm.hlfxzts = parseInt(this.ruleForm.hlfxzts);
                    this.ruleForm.zjdbfb = parseFloat(this.ruleForm.zjdbfb);
                    this.ruleForm.bzjzbljbfb = parseFloat(this.ruleForm.bzjzbljbfb);
                    this.ruleForm.wyjzbljbfb = parseFloat(this.ruleForm.wyjzbljbfb);
                    this.ruleForm.yjzcjjbfb = parseFloat(this.ruleForm.yjzcjjbfb);
                    if(this.ruleForm.sfkygg == 'true'){
                        this.ruleForm.sfkygg = true;
                    }
                    else{
                        this.ruleForm.sfkygg = false;
                    }
                    if(this.ruleForm.sflhpm == 'true'){
                        this.ruleForm.sflhpm = true;
                    }
                    else{
                        this.ruleForm.sflhpm = false;
                    }
                    if(this.ruleForm.jmrsxz == 'true'){
                        this.ruleForm.jmrsxz = true;
                    }
                    else{
                        this.ruleForm.jmrsxz = false;
                    }
                    addData(this.ruleForm).then((res) => {
                        if(res){
                            this.$message.success('提交成功');
                            // console.log(res.msg);
                            // this.dialogClose();
                            console.log(res.data);
                            this.wthtbh = res.data;
                        }
                    })
                // }
                // else {
                //     return ;
                // }
            // });
        },
        formatTime(time){
            var dateee = new Date(time).toJSON();
            return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '');
        },
        dialogClose () {
            this.$emit('dialogClose');
        },
        submit(e){
            console.log(e);
            console.log('合并前',this.ruleForm);
            this.ruleForm = Object.assign(this.ruleForm, e);
            console.log('合并后',this.ruleForm);
            this.$message.success('保存成功');
        },
        submitFinal(e){
            console.log(e);
            console.log('合并前',this.ruleForm);
            this.ruleForm = Object.assign(this.ruleForm, e);
            console.log('合并后',this.ruleForm);
            this.submitForm();
        },
        submitLot(e){
            addLotData(e).then((res) => {
                if(res){
                    console.log(res);
                    this.dialogClose();
                }
            })
        },
        
        
    }

}
</script>
<style lang="less" scoped>

</style>